package com.yenlien.traceyun.breed.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.yenlien.traceyun.breed.service.MotionTrailService;
import com.yenlien.traceyun.business.interceptor.DataAuth;
import com.yenlien.traceyun.webase.controller.BaseController;

/**
 * 轨迹控制层
 *
 * @author maybe
 * @date 2020年9月28日
 */
@RestController
@RequestMapping("/motionTrail")
public class MotionTrailController extends BaseController {
    @Autowired
    private MotionTrailService motionTrailService;

    //查询所有设备最近的一个点
    @DataAuth
    @RequestMapping(value = "/findAllCoordinate", method = RequestMethod.GET)
    public Object findAllCoordinate() {
        return success(motionTrailService.findAllCoordinate());
    }

    //根据设备ID查询养殖详情
    @RequestMapping(value = "/findByEquipmentId/{equipmentId}", method = RequestMethod.GET)
    public Object findByEquipmentId(@PathVariable("equipmentId") String equipmentId) {
        return success(motionTrailService.findByEquipmentId(equipmentId));
    }

    //查询所有养殖批次
    @DataAuth
    @RequestMapping(value = "/findAllBatch", method = RequestMethod.GET)
    public Object findAllBatch() {
        return success(motionTrailService.findAllBatch());
    }

    //根据养殖ID查询设备信息
    @RequestMapping(value = "/findEquipment/{breedId}", method = RequestMethod.GET)
    public Object findEquipment(@PathVariable("breedId") String breedId) {
        return success(motionTrailService.findEquipment(breedId));
    }

    //根据条件查询轨迹(养殖ID、设备ID)
    @RequestMapping(value = "/findMotionTrail", method = RequestMethod.POST)
    public Object findMotionTrail(@RequestBody JSONObject params) {
        return success(motionTrailService.findMotionTrail(params));
    }

}
